function doempspark(pos, magnitude)
	zap = ents.Create("point_tesla")
	zap:SetKeyValue("targetname", "teslab")
	zap:SetKeyValue("m_SoundName" ,"DoSpark")
	zap:SetKeyValue("texture" ,"sprites/plasma.spr")
	zap:SetKeyValue("m_Color" ,"220 255 255")
	zap:SetKeyValue("m_flRadius" ,tostring(magnitude*80))
	zap:SetKeyValue("beamcount_min" ,tostring(math.ceil(magnitude)+4))
	zap:SetKeyValue("beamcount_max", tostring(math.ceil(magnitude)+12))
	zap:SetKeyValue("thick_min", tostring(magnitude))
	zap:SetKeyValue("thick_max", tostring(magnitude*8))
	zap:SetKeyValue("lifetime_min" ,"0.1")
	zap:SetKeyValue("lifetime_max", "0.2")
	zap:SetKeyValue("interval_min", "0.05")
	zap:SetKeyValue("interval_max" ,"0.08")
	zap:SetPos(pos)
	zap:Spawn()
	zap:Fire("DoSpark","",0)
	zap:Fire("kill","", 1)
end

function empattack(ply,ent,resettime)
Msg("EMP ATTACK")
if ent:GetClass() == "prop_vehicle_jeep" or ent:GetClass() == "prop_vehicle_airboat" then
ent:Fire("TurnOff","",0)
ent:Fire("TurnOn","",resettime)
ent:Fire("HandBrakeOn","",0)
ent:Fire("HandBrakeOff","",resettime)
end
if ent:GetClass() == "prop_vehicle_prisoner_pod" then
ent:Fire("Lock","",0)
ent:Fire("Unlock","",resettime)
end
if ent:GetClass() == "gmod_wheel" then
local torq = ent.BaseTorque
local torq2 = ent.BaseTorque * ent.TorqueScale
timer.Simple(resettime,resetemptorq,ent,torq,torq2)
ent:SetBaseTorque( 1 )
ent:SetTorque( 0 )
elseif ent:GetClass() == "gmod_thruster" then
local power = ent.force
timer.Simple(resettime,resetempforce,ent,power)
ent:SetForce(0)
elseif ent:GetClass() == "gmod_hoverball" then
local speed = ent:GetSpeed()
ent:SetSpeed(0)
timer.Simple(resettime,resetempspeed,ent,speed)
elseif ((ent:GetClass() == "energy_cell") or (ent:GetClass() == "res_cache"))then
RD_ConsumeResource(ent, "energy", RD_GetResourceAmount(ent,"energy")/2)
end
end

function resetempforce(ent,power)
if !ent:IsValid() then return end
ent:SetForce( force )
end

function resetempspeed(ent,speed)
if !ent:IsValid() then return end
ent:SetSpeed( speed )
end

function resetemptorq(ent,torq,torq2)
if !ent:IsValid() then return end
ent:SetBaseTorque( torq )
ent:SetTorque( torq2 )
end
